import request from '@/utils/request'

const API_NAME = '/admin/edu/teachers'

export default {
  // 获取所有讲师
  queryAll() {
    return request({
      url: `${API_NAME}/`,
      method: 'get'
    })
  },
  // 分页获取所有讲师
  queryByPage(page, limit, searchObj) {
    return request({
      url: `${API_NAME}/${page}/${limit}`,
      method: 'get',
      params: searchObj
    })
  },
  // 根据ID删除讲师
  deleteById(id) {
    return request({
      url: `${API_NAME}/${id}`,
      method: 'delete'
    })
  },
  // 新增一个讲师
  insert(teacher) {
    return request({
      url: `${API_NAME}/`,
      method: 'post',
      data: teacher
    })
  },
  // 根据ID获取一个讲师
  queryById(id) {
    return request({
      url: `${API_NAME}/${id}`,
      method: 'get'
    })
  },
  // 修改一个讲师
  update(teacher) {
    return request({
      url: `${API_NAME}/`,
      method: 'put',
      data: teacher
    })
  },
  // 根据ID批量删除讲师
  deleteByIds(idList) {
    return request({
      url: `${API_NAME}/batch-delete`,
      method: 'post',
      data: idList
    })
  },
  // 根据姓氏获取讲师姓名列表
  queryNamesByKey(key) {
    return request({
      url: `${API_NAME}/names/${key}`,
      method: 'get',
    })
  },
  // 导出讲师
  output(list) {
    return request({
      url: `${API_NAME}/output`,
      method: 'post',
      data: list
    })
  },
  // 获取讲师数量
  count(){
    return request({
      url: `${API_NAME}/count`,
      method: 'get'
    })
  }

}
